package com.jiexinyun.enums;

public enum DbType {

    /**
     * MYSQL
     */
//    MYSQL("1", "MySql数据库", "jdbc:mysql://${host}:${port}/${dbName}?serverTimezone=GMT%2B8&characterEncoding=UTF-8&useUnicode=true&useSSL=false&rewriteBatchedStatements=true"),
    /**
     * MARIADB
     */
//    MARIADB("2", "MariaDB数据库", "jdbc:mariadb://${host}:${port}/${dbName}"),
    /**
     * ORACLE
     */
//    ORACLE("3", "Oracle11g及以下数据库", "jdbc:oracle:thin:@${host}:${port}:${sid}"),
    /**
     * oracle12c new pagination
     */
//    ORACLE_12C("4", "Oracle12c+数据库", "jdbc:oracle:thin:@//${host}:${port}/${service_name}"),

    /**
     * POSTGRESQL
     */
    POSTGRE_SQL("5", "PostgreSql数据库", "jdbc:postgresql://${host}:${port}/${dbName}?currentSchema=${schema}&characterEncoding=UTF-8","org.postgresql.Driver"),
    /**
     * SQLSERVER2005
     */
    SQL_SERVER2008("6", "SQLServer2008及以下数据库", "jdbc:sqlserver://${host}:${port};databaseName=${dbName};schemaName=${schema}","com.microsoft.sqlserver.jdbc.SQLServerDriver"),

    /**
     * SQLSERVER
     */
//    SQL_SERVER("7", "SQLServer2012+数据库", "jdbc:sqlserver://${host}:${port};DatabaseName=${dbName};encrypt=false;trustServerCertificate=true"),
    /**
     * UNKONWN DB
     */
    OTHER("8", "其他数据库", "");

//    VERTICA("31", "Vertica数据库", "jdbc:vertica://${host}:${port}/${dbName}"),

//    CLICKHOUSE("35", "Clickhouse数据库", "jdbc:clickhouse://${host}:${port}/${dbName}"),

//    KAFKA("90", "Kafka流式数据库", "${host}:${port}"),

//    ELASTICSEARCH("100", "Elasticsearch数据库", "${host}:${port}"),

//    MONGODB("101", "Mongodb数据库", "mongodb://${user}:${pass}@${host}:${port}/");

    /**
     * 数据库类型码值
     */
    private final String dbType;

    /**
     * 描述
     */
    private final String desc;

    /**
     * url
     */
    private final String url;
    /*
     * 驱动类名
     */
    private final String driverClassName;

    public String getDbType() {
        return this.dbType;
    }

    public String getDesc() {
        return this.desc;
    }

    public String getUrl() {
        return this.url;
    }

    public String getDriverClassName() {
        return this.driverClassName;
    }

    DbType(String dbType, String desc, String url) {
        this.dbType = dbType;
        this.desc = desc;
        this.url = url;
        this.driverClassName = null;
    }

    DbType(String dbType, String desc, String url, String driverClassName) {
        this.dbType = dbType;
        this.desc = desc;
        this.url = url;
        this.driverClassName = driverClassName;
    }

    /**
     * 获取数据库类型
     *
     * @param dbType 数据库类型字符串
     */
    public static DbType getDbType(String dbType) {
        for (DbType type : DbType.values()) {
            if (type.dbType.equals(dbType)) {
                return type;
            }
        }
        return OTHER;
    }
}
